#include <iostream>
using namespace std;

#include "User.hpp"
#include "BusinessLogic.hpp"
#include "Status.hpp"

void test_login(BusinessLogic *bl)
{
	// Create some username/password pairs to test
	// It's the following mess in C++
	// wouldn't users = [(name1, password1), (name2, password2)] be nice?
	vector<vector<string> > users;
	
	// Invalid Name
	vector<string> user;
	user.push_back("John");
	user.push_back("bacon");
	users.push_back(user);
	
	// Valid Name, Valid Password
	user = vector<string>();
	user.push_back("Bob");
	user.push_back("test");
	users.push_back(user);
	
	// Valid Name, Invalid Password
	user = vector<string>();
	user.push_back("Carl");
	user.push_back("wrong_password");
	users.push_back(user);

	// Run though the users and test loggin in..
	for(vector<vector<string> >::iterator it = users.begin(); it < users.end(); ++it)
	{
		user = *it;
		cout << "Testing Login (Name=" << user[0] << ", Password=" << user[1] << ")" << endl;
		
		switch (bl->login(user[0], user[1]))
		{
			case LoginSuccess:
				cout << "Login Successful" << endl;
				break;
				
			case LoginInvalidUser:
				cout << "Login Failed: Invalid User" << endl;
				break;
				
			case LoginInvalidPassword:
				cout << "Login Failed: Invalid Password" << endl;
				break;
		}
	}	
}

int main(int argc, char **argv)
{
	if (argc == 1) return -1;
	BusinessLogic bl(argv[1]);
	
	test_login(&bl);
		
	return 0;
}
